<!--
 * @Description: 头部
 * @Author: lixx
 * @Date: 2025-09-24 16:04:25
 * @LastEditTime: 2025-10-09 15:44:05
 * @LastEditors: lixx
-->
<template>
  <div class="header">
    <div class="l-content">
      <el-button @click="handleCollapse">
        <component class="icons" is="Menu"></component>
      </el-button>
      <el-breadcrumb separator="/" class="bread">
        <el-breadcrumb-item :to="{ path: '/' }">首页</el-breadcrumb-item>
      </el-breadcrumb>
    </div>
    <div class="r-content">
      <el-dropdown>
        <span class="el-dropdown-link">
          <img :src="getImageUrl('user')" class="user" />
        </span>
        <template #dropdown>
          <el-dropdown-menu>
            <el-dropdown-item @click="handleClick">个人中心</el-dropdown-item>
            <el-dropdown-item @click="handleLoginOut">退出</el-dropdown-item>
          </el-dropdown-menu>
        </template>
      </el-dropdown>
    </div>
  </div>
</template>
<script setup>
import { ref, computed } from "vue";
import { useAllDateStore } from "../stores";
import { useRouter } from "vue-router";

const router = useRouter();

const getImageUrl = (user) => {
  return new URL(`../assets/images/${user}.png`, import.meta.url).href; // 以后面的当前模块的完整url为基准解析第一个参数的相对路径
};

const store = useAllDateStore();

const handleCollapse = () => {
  store.state.isCollapse = !store.state.isCollapse;
};

// 退出
const handleLoginOut = ()=>{
  store.clean()
  router.push('/login')
}
</script>
<style lang="less" scoped>
.header {
  width: 100%;
  height: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.user {
  width: 40px;
  height: 40px;
  cursor: pointer;
}
.l-content {
  display: flex;
  align-items: center;
  .el-button {
    margin-right: 20px;
  }
}
.icons {
  width: 20px;
  height: 20px;
}
:deep(.bread span) {
  color: #fff !important;
  cursor: pointer !important;
}
</style>
